# coding=utf-8
from ronglian_sms_sdk import SmsSDK
import random
from datetime import datetime

accId = '2c94811c9035ff9f0190a9e7f4b61b65'
accToken = '06a132414fe34f5abd43d0c91765a8dc'
appId = '2c94811c9035ff9f0190a9e7f6401b6c'

def send_sms(mobile,code):
    sdk = SmsSDK(accId, accToken, appId)
    tid = '1'
    mobile = mobile #可以设置2个手机号
    datas = (code,5) #变量1表示发送验证码，变量2表示有效时间
    resp = sdk.sendMessage(tid, mobile, datas)
    #print(resp)
    result = {
        'datatime':datetime.now(),
        'phone':mobile,
        'code':code,
        'Message':'OK',
        'Code':'OK'
    }
    #print(result)
    return result

if __name__ == '__main__':
    send_sms(mobile='13695152602',code=random.randint(1000,9999))
